package com.robot.service.impl;

import com.robot.dao.dto.EnterpriseDTO;
import com.robot.dao.entity.Enterprise;

import com.robot.dao.mapper.EnterpriseMapper;
import com.robot.service.EnterpriseService;
import com.robot.dao.vo.EnterpriseVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Slf4j
@Service
public class EnterpriseServiceImpl  implements EnterpriseService {

    @Autowired
    private EnterpriseMapper enterpriseMapper;

    /**
     * 新建企业
     * @param enterpriseDTO
     * @return
     */
    public EnterpriseVO create(EnterpriseDTO enterpriseDTO) {
        Enterprise enterprise = new Enterprise();
        enterprise.setEnterpriseName(enterpriseDTO.getEnterpriseName());
        enterpriseMapper.create(enterprise);
        EnterpriseVO enterpriseVO = new EnterpriseVO();
        BeanUtils.copyProperties(enterprise, enterpriseVO);
        enterpriseVO.setEnterpriseId(String.valueOf(enterprise.getId()));
        return enterpriseVO;
    }
}
